﻿// <com.woyouqiu.Copyright>
// --------------------------------------------------------------
// <copyright>上海有求网络科技有限公司 2015</copyright>
// <Solution>Vecen.BangChuang</Solution>
// <Project>Vecen.BangChuang.Core</Project>
// <FileName>ProductDeleteAfterEventHandler.cs</FileName>
// <CreateTime>2017-05-23 22:38</CreateTime>
// <Author>何苗</Author>
// <Email>hemiao@woyouqiu.com</Email>
// <log date="2017-05-23 22:38" version="00001">创建</log>
// --------------------------------------------------------------
// </com.woyouqiu.Copyright>

using Abp.Dependency;
using Abp.Events.Bus.Handlers;
using Abp.Threading;
using Vecen.BangChuang.BangChuang.DomainServices.EventHandlers.EventDatas;
using Vecen.BangChuang.BangChuang.DomainServices.Mall;

namespace Vecen.BangChuang.BangChuang.DomainServices.EventHandlers {

    /// <summary>
    /// 商品删除后事件
    /// </summary>
    public class ProductDeleteAfterEventHandler: IEventHandler<ProductDeleteAfterEventData>, ITransientDependency {
        private readonly OrderDomainService _orderDomainService;

        public ProductDeleteAfterEventHandler(OrderDomainService orderDomainService) {
            _orderDomainService = orderDomainService;
        }

        public void HandleEvent(ProductDeleteAfterEventData eventData) {
            AsyncHelper.RunSync(() => _orderDomainService.DeleteOrderWithProductIdAsync(eventData.ProductId));
        }
    }
}